package com.whros.android.sample.helper;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;

/**
 * Created by whroi on 2017/6/11.
 */

public class BitmapHelper {

    public final static String TAG = "BitmapHelper";
    public static void printBitmapSize(Drawable drawable){
        if(null == drawable ){
            throw  new NullPointerException("drawable should not null.");
        }
        if(drawable instanceof BitmapDrawable){
            BitmapDrawable bd = (BitmapDrawable)drawable;
            Bitmap bitmap = bd.getBitmap();
            Log.i(TAG,String.format("bitmap  width=%d,height=%d,size=%d, ----  drawable width=%d,height=%s",bitmap.getWidth(),bitmap.getHeight(),(bitmap.getRowBytes()*bitmap.getHeight()),drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight()));
        }
    }
}
